package org.vz.webservice.config;

import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.vz.webservice.service.HelloPortImpl;

import javax.xml.ws.Endpoint;

@Configuration
public class WebServiceConfig {

    @Bean
    public ServletRegistrationBean vzDispatcher() {//这里不能用dispatcherServlet()会覆盖默认的"dispatherServlet"过滤"/"

        return new ServletRegistrationBean(new CXFServlet(),
                "/ws/*");

    }
    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus() {
        return new SpringBus();
    }

    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), new HelloPortImpl());
        endpoint.publish("/abc");
        return endpoint;
    }
}